package com.jianggujin.test.module;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.jianggujin.modulelink.action.JAbstractAction;
import com.jianggujin.modulelink.action.JAction;
import com.jianggujin.modulelink.action.JActionWrapper;
import com.jianggujin.modulelink.action.JActiveAction;
import com.jianggujin.modulelink.action.JModuleContext;
import com.jianggujin.modulelink.config.JModuleConfig;
import com.jianggujin.modulelink.exception.JModuleLinkException;
import com.jianggujin.modulelink.support.annotation.JInject;
import com.jianggujin.modulelink.test.CustomAction;

/**
 * 自定义Action
 * 
 * @author jianggujin
 *
 */
public class Action2 extends JAbstractAction implements CustomAction, JActiveAction {

    @JInject("now")
    private Object now;
    @JInject
    private Map<String, JAction> actionMap;
    @JInject
    private List<Object> beans;
    @JInject
    private Date[] nows;
    @JInject
    private JModuleConfig config;
    @JInject("testActionA")
    private JAction action;
    @JInject
    private JAction[] actions;
    @JInject
    private JActionWrapper[] actions2;

    @Override
    public Object execute(Object in) throws JModuleLinkException {
        System.out.println(JModuleContext.getActionNames());
        return this.getClass().getName();
    }

    @Override
    public void handle() {
        System.out.println("invoke handle method. now:" + now);
        System.out.println("invoke handle method. actionMap:" + actionMap);
        System.out.println("invoke handle method. beans:" + beans);
        System.out.println("invoke handle method. nows:" + Arrays.toString(nows));
        System.out.println("invoke handle method. config:" + config);
        System.out.println("invoke handle method. action:" + action);
    }

    @Override
    public void active() {
        System.err.println("active...");
        System.err.println("actionMap:" + actionMap);
        System.err.println("beans:" + beans);
        System.err.println("actions:" + Arrays.toString(actions));
        System.err.println("actions2:" + Arrays.toString(actions2));
    }

    @Override
    public void unActive() {

    }
}